//
//  LOLTopViewXib.m
//  LOLNews
//
//  Created by MXL on 16/10/28.
//  Copyright © 2016年 KK. All rights reserved.
//

#import "LOLTopViewXib.h"

@interface LOLTopViewXib ()

@property (weak, nonatomic) IBOutlet UIButton *friendBtn;

@property (weak, nonatomic) IBOutlet UIButton *newsBtn;

@property (nonatomic,weak) UIButton *selectedBtn;

@property (weak, nonatomic) IBOutlet UIView *tiaoView;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *tiaoLeading;

@end

@implementation LOLTopViewXib

- (void)awakeFromNib{
    self.friendBtn.selected = YES;
    self.friendBtn.userInteractionEnabled = NO;
    self.selectedBtn = self.friendBtn;
}

+ (instancetype)topViewXib{
    
    return [[NSBundle mainBundle]loadNibNamed:@"LOLTopViewXib" owner:nil options:nil].lastObject;
    
}
#pragma mark - btn 响应
- (IBAction)btnAnswer:(UIButton *)sender {
    // 改变选择状态
    self.selectedBtn.selected = NO;
    self.selectedBtn.userInteractionEnabled = YES;
    self.selectedBtn = sender;
    self.selectedBtn.selected = YES;
    self.selectedBtn.userInteractionEnabled = NO;
    
    CGFloat distance = self.frame.size.width - sender.bounds.size.width*2 -100*2+sender.bounds.size.width;
//    NSLog(@"%.2f",distance);
    
    self.tiaoLeading.constant += sender.tag?-distance:distance;
    
}

@end
